export default function wxAuth() {
  var nowUrl = window.location.href
  var redirectUri = window.location.href
  // var redirectUri = 'm.yuanpinren.com';

  if (nowUrl.indexOf('code') > 0) {
    var temp = nowUrl.split('code=')[1]
    var wxCode = temp.split('&')[0]
    // var data = await WxLoginRequest(wxCode);
    return wxCode;
  } else {
    // return 1;
    document.location = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5f9e44c76d624d60&redirect_uri=' + encodeURIComponent(redirectUri) + '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';

    return 2;
  }
}
